/**
 * CopyRight © 2012 USTC SINOVATE SOFTWARE CO.LTD All Rights Reserved.
 */

package com.cmcc.zysoft.infocollection.service;

import java.text.ParseException;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.cmcc.zysoft.infocollection.dao.LoginOutLogPcDao;
import com.cmcc.zysoft.infocollection.dto.LoginOutLogDto;
import com.cmcc.zysoft.infocollection.model.LoginOutLog;
import com.starit.common.dao.hibernate.HibernateBaseDao;
import com.starit.common.dao.service.BaseServiceImpl;

/**
 * @author 袁凤建
 * <br />邮箱: yuan.fengjian@ustcinfo.com
 * <br />描述: LoginOutLogPcService.java
 * <br />版本: 1.0.0
 * <br />日期: 2013-9-12 上午9:42:47
 * <br />CopyRight © 2012 USTC SINOVATE SOFTWARE CO.LTD All Rights Reserved.
 */

@Service
public class LoginOutLogPcService extends BaseServiceImpl<LoginOutLog, Long> {
	
	/**
	 * 日志.
	 */
	private static final Logger logger = LoggerFactory.getLogger(LoginOutLogPcService.class);
	
	@Resource
	private  LoginOutLogPcDao loginOutLogPcDao;

	@Override
	public HibernateBaseDao<LoginOutLog, Long> getHibernateBaseDao() {
		return this.loginOutLogPcDao;
	}
	
	/**
	 * 保存日志.
	 * @param log 
	 * @return 
	 * 返回类型：int
	 */
	public Long saveLog(LoginOutLog log) {
		logger.debug("#保存登录-注销日志到数据库");
		return this.loginOutLogPcDao.saveLog(log);
	}
	
	/**
	 * 登录日志记录 可根据登录时间查询.
	 * @param rows 
	 * @param page 
	 * @param startTime 
	 * @param endTime 
	 * @return map
	 */
	public Map<String, Object> list(int rows, int page, String startTime, String endTime) {
		return this.loginOutLogPcDao.list(rows, page, startTime, endTime);
	}
	
	/**
	 * 登陆日志导出.
	 * @param startTime 
	 * @param endTime 
	 * @return list
	 * @throws ParseException 
	 * @throws ParseException 
	 */
	public List<LoginOutLogDto> getListForExcel(String startTime, String endTime) throws ParseException {
		return this.loginOutLogPcDao.getListForExcel(startTime, endTime);
	}
	
	/**
	 * 删除日志. 
	 * @param logId 
	 */
	public void deleteById(String logId) {
		this.loginOutLogPcDao.delete(Long.parseLong(logId));
	}
	
	/**
	 * 首页-最新动态.
	 * @param companyId 企业ID
	 * @return List<Map<String, Object>>
	 */
	public List<Map<String, Object>> latestDynamic(String companyId) {
		return this.loginOutLogPcDao.latestDynamic(companyId);
	}
}